package com.ruoyi.manage.article.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.manage.article.domain.DataExchanges;
import com.ruoyi.manage.article.service.IDataExchangesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 存储各个数据交易所的相关信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-18
 */
@RestController
@RequestMapping("/article/excvhanges")
public class DataExchangesController extends BaseController
{
    @Autowired
    private IDataExchangesService dataExchangesService;

    /**
     * 查询存储各个数据交易所的相关信息列表
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataExchanges dataExchanges)
    {
        startPage();
        List<DataExchanges> list = dataExchangesService.selectDataExchangesList(dataExchanges);
        return getDataTable(list);
    }

    /**
     * 导出存储各个数据交易所的相关信息列表
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:export')")
    @Log(title = "存储各个数据交易所的相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataExchanges dataExchanges)
    {
        List<DataExchanges> list = dataExchangesService.selectDataExchangesList(dataExchanges);
        ExcelUtil<DataExchanges> util = new ExcelUtil<DataExchanges>(DataExchanges.class);
        util.exportExcel(response, list, "存储各个数据交易所的相关信息数据");
    }

    /**
     * 获取存储各个数据交易所的相关信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dataExchangesService.selectDataExchangesById(id));
    }

    /**
     * 新增存储各个数据交易所的相关信息
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:add')")
    @Log(title = "存储各个数据交易所的相关信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataExchanges dataExchanges)
    {

        return toAjax(dataExchangesService.insertDataExchanges(dataExchanges));
    }

    /**
     * 修改存储各个数据交易所的相关信息
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:edit')")
    @Log(title = "存储各个数据交易所的相关信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataExchanges dataExchanges)
    {
        return toAjax(dataExchangesService.updateDataExchanges(dataExchanges));
    }

    /**
     * 删除存储各个数据交易所的相关信息
     */
    @PreAuthorize("@ss.hasPermi('article:excvhanges:remove')")
    @Log(title = "存储各个数据交易所的相关信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataExchangesService.deleteDataExchangesByIds(ids));
    }
}
